|
|
 |
|
|
|
|
Dim M56(1 To 4, 1 To 4) As Single
Dim M567(1 To 4, 1 To 4) As Single
' Translate the plane to the origin. m3Translate T, -p1, -p2, -p3
m3Translate Ti, p1, p2, p3
' Rotate around Z-axis until the line is in
' the Y-Z plane. m3Identity R1
D = Sqr(d1 * d1 + d2 * d2)
R1(1, 1) = d2 / D
R1(1, 2) = d1 / D
R1(2, 1) = -R1(1, 2)
R1(2, 2) = R1(1, 1)
m3Identity R1i
R1i(1, 1) = R1(1, 1)
R1i(1, 2) = -R1(1, 2)
R1i(2, 1) = -R1(2, 1)
R1i(2, 2) = R1(2, 2)
' Rotate around the X-axis until the line
' lies along the Y axis. m3Identity R2
L = Sqr(d1 * d1 + d2 * d2 + d3 * d3)
R2(2, 2) = D / L
R2(2, 3) = -d3 / L
R2(3, 2) = -R2(2, 3)
R2(3, 3) = R2(2, 2)
m3Identity R2i
R2i(2, 2) = R2(2, 2)
R2i(2, 3) = -R2(2, 3)
R2i(3, 2) = -R2(3, 2)
R2i(3, 3) = R2(3, 3)
' Rotate around the line (Y axis). m3YRotate Rot3, theta
' Combine the matrices. m3MatMultiply M12, T, R1
m3MatMultiply M34, R2, Rot3
m3MatMultiply M1234, M12, M34
m3MatMultiply M56, R2i, R1i
m3MatMultiply M567, M56, Ti
m3MatMultiply M, M1234, M567
End Sub |
|
|
|
|
|